package com.example.base.app;

import java.util.*;

public class AppUtils {

    public static final String SYSTEM_MAIN_APP="system";

    static {
        APP_MAP=new HashMap<>();
        CLS_APP_MAP=new HashMap<>();
        CLS_NAME_MAP=new HashMap<>();
    }

    private static Map<String,App> APP_MAP;

    private static Map<String,String> CLS_APP_MAP;

    private static Map<String,Class<?>> CLS_NAME_MAP;

    public static void add(String name,App app){
        APP_MAP.put(name,app);
    }

    public static String getSystemAppName(){
        return SYSTEM_MAIN_APP;
    }

    public static App getApp(String name){
        return APP_MAP.get(name);
    }

    public static List<String> getClsListByAppName(String appName){
        List<String> strings=new ArrayList<>();
        for (Map.Entry<String,String> cls_app_map:CLS_APP_MAP.entrySet()){
            if(cls_app_map.getValue().equals(appName)){
                   strings.add(cls_app_map.getKey());
            }
        }
        return strings;
    }

    public static List<App> getAllapp(){
        return new ArrayList<>(APP_MAP.values());
    }

    public static void addCLS_APP(String clsName,String appName){
        CLS_APP_MAP.put(clsName,appName);
    }

    public static String getAppName(String clsName){
        return CLS_APP_MAP.get(clsName);
    }

    public static void addCLS_NAME(String name,Class<?> cls){
        CLS_NAME_MAP.put(name,cls);
    }

    public static Class<?> getCLsByClsName(String clsName){
        return CLS_NAME_MAP.get(clsName);
    }


}
